<template>
  <div class='form-model'>
    <div v-for="item in dataArray" class="item-box">
      <span :title="item.title"><span class="real-title">{{item.title}}</span></span>
      <el-input v-if="item.type=='input'" v-model="data[item.key]" placeholder="" @change="changeThis"></el-input>

      <el-date-picker
        v-if="item.type=='date'"
        v-model="data[item.key]"
        type="date"
        placeholder="选择日期"
         @change="changeThis">
      </el-date-picker>

      <el-date-picker
        v-if="item.type=='month'"
        v-model="data[item.key]"
        type="month"
        placeholder="选择年月"
         @change="changeThis">
      </el-date-picker>

      <el-select v-if="item.type=='select'" v-model="data[item.key]" filterable clearable placeholder="请选择"  @change="changeThis">
        <el-option
          v-for="(option,index) in item.array"
          :key="index"
          :label="option.label?option.label:option"
          :value="option.value?option.value:option">
        </el-option>
      </el-select>

    </div>
  </div>
</template>
<script>
export default {
  props:["dataArray","data"],
  components: {},
  name: "",
  data() {
    return {};
  },
  methods: {
    changeThis(){
      
    }
  },
  created() {},
  mounted() {
    if(bus._events.baseInfoSaved!==null){
      bus.$off("baseInfoSaved")
    }
    bus.$on("baseInfoSaved",()=>{
      var params={}
      for(var key in this.data){
        if(key!="state"&&key!="state_info")params[key]=this.data[key]
      }
      
      if(params.addjob)params.addjob=_g.formatTime(params.addjob,"month")
      if(params.birthday)params.birthday=_g.formatTime(params.birthday)
      if(params.addschool)params.addschool=_g.formatTime(params.addschool)
      
      this.apiPost("teacher_manage/infoBaseUpdate",params).then(res=>{
        _g.toastMsg(res.error?"error":"success",res.msg)
      })
    })
  },
};
</script>
<style scoped>
.form-model{
  display: flex;
  flex-wrap: wrap;
  border-left: 1px solid #E4E4E4;
}
.form-model .item-box{
  width:calc(100%/6);
  /* max-width: 230px; */
  height: 45px;
  box-sizing: border-box;
  flex-flow: 1;
}
.form-model .item-box>span{
  float: left;
  width: 40%;
  line-height: 44px;
  height: 45px;
  overflow: hidden;
  color: #666;
  font-size: 12px;
  box-sizing: border-box;
  /* padding-right: 3px; */
  text-align: center;
  background-color: #f9fafc;
  border-bottom: 1px solid #E4E4E4;
  border-right: 1px solid #E4E4E4;
  position: relative;
}
.real-title{
  position: absolute;
  width: 100%;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  line-height: 20px;
}
</style>